<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<c:set value="${requestScope.response.data.one }" var="one"/>
<c:set value="${requestScope.cateList.data.list }" var="cateResponse" />
<jsp:useBean id="pojo" class="com.zxq.lawenf.pojo.ACase"/>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<title>添加案件 - 综合性执法系统</title>
		<%@ include file="/common/include/head_title.jsp"%>
	    <link rel="stylesheet" href="${rootPath }/common/resource/bootstrapvalidator/css/form-validation.css" rel="stylesheet">
	  	<script type="text/javascript" src="${rootPath }/common/resource/bootstrapvalidator/js/form-validation.js"></script>
	  	
	  	<script language="javascript" type="text/javascript" src="${rootPath }/common/resource/My97DatePicker/WdatePicker.js"></script>
	  	
	  	<script type="text/javascript" charset="utf-8" src="${rootPath }/common/resource/ueditor/ueditor.config.js"></script>
	    <script type="text/javascript" charset="utf-8" src="${rootPath }/common/resource/ueditor/ueditor.all.min.js"> </script>
	    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
	    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
	    <script type="text/javascript" charset="utf-8" src="${rootPath }/common/resource/ueditor/lang/zh-cn/zh-cn.js"></script>
	  	
	  	<script type="text/javascript">
	  		$(function()
			{
	  			/* 表单验证 */
			  	$("#form").FormValidation({
		  			fields:
	  				{
		  				/* 名称 */
		  				name:
	  					{
		  					validators: {
		  	                    notEmpty: {
		  	                        message: '名称不能为空'
		  	                    }
		  	                }
	  					},
	  					/* qq */
		  				content:
	  					{
		  					validators: {
		  	                    notEmpty: {
		  	                        message: '内容不能为空'
		  	                    }
		  	                }
	  					}
	  				}
				});
	  			
			  	/* 百度编辑器 */
			  	var ue = UE.getEditor('editor');
			  	
			  	switchCate("cateId");
			});
	  		
	  		
	  		var ue = UE.getEditor('editor');
	  		
	  		var cateData = ${cateResponse};
	  		/**
	  			切换模板
	  		*/
	  		function switchCate(selectId)
	  		{
	  			/* 获取选中的值 */
	  			var selectVal = $("#" + selectId).val();
	  			if(selectVal == '')
				{
	  				ue.setContent('');
				}
	  				
	  			/* 循环模板里面的数据 */
	  			for(var i = 0 ; i < cateData.length ; i ++)
  				{
	  				/* 获取指定元素的数据 */
  					var cateTemp = cateData[i] ; 
	  				if(selectVal == cateTemp.id)
	  				{
	  					ue.ready(function()
						{
		  					/* 找到模板 */
		  					ue.setContent(cateTemp.content);
						})
	  				}
  				}
	  		}
	  	</script>
	</head>
	<body>
		<%@ include file="/common/include/head_header.jsp"%>
		<!-- 网页的主体 -->
		<div class="container">
			<div class="col-md-8 col-sm-10">
				<form id="form" method="post" class="form-horizontal" action="${rootPath }/head/lawEnf/caseInsertSubmit.htm">
					<input type="hidden" name="operType" value="${param.operType }">
	
					<h2
						class="col-sm-10 col-sm-offset-1 form-signin-heading text-center">添加案件</h2>
					
					<div class="form-group">
						<label for="inputPassword" class="col-sm-3 control-label">名称</label>
						<div class="col-sm-8">
							<input type="text" name="name" id="name" value="${one.name }"
								class="form-control" placeholder="名称" />
						</div>
					</div>
					<div class="form-group">
						<label for="email" class="col-sm-3 control-label">类型</label>
						<div class="col-sm-8">
							<select name="appType" class="form-control">
								<c:set value="1" var="currCount"/>
								<c:forEach items="${pojo.enumsMap }" var="me" varStatus="stat">
									<c:if test="${fn:startsWith(me.key,'APPTYPE')}">
										<!-- 拆分,按照-拆分,取最后一个 -->
										<c:set value="${fn:split(me.key, '-')}" var="keys"/>
										<option value="${keys[1] }" ${currCount == 1  ? 'selected' : '' }>${me.value }</option>
										<c:set value="${currCount + 1 }" var="currCount"/>
									</c:if>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label for="email" class="col-sm-3 control-label">模板</label>
						<div class="col-sm-8">
							<select name="cateId" id="cateId" class="form-control" onchange="switchCate('cateId')">
								<option value="">请选择</option>
								<c:forEach items="${cateResponse }" var="temp" varStatus="stat">
									<option value="${temp.id }" >${temp.name }(${temp.cateTypeStr })</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label for="email" class="col-sm-3 control-label">内容</label>
						<div class="col-sm-8">
							<script name="content" id="editor" type="text/plain"
							style="width: 800px; height: 400px;">${one.content}</script>
						</div>
					</div>
					
					<div class="form-group">
						<label for="status" class="col-sm-2 control-label">状态:</label>
						</div>
						<div class="form-group">
							<div class="col-sm-8 form-check form-check-inline">
								&nbsp;&nbsp;&nbsp;&nbsp;
								<label for="status0" class="form-check-label">
									<input type="radio" id="status0" name="status" class="form-check-input" value="0" checked="checked">
									草稿
								</label>
								&nbsp;&nbsp;
								<label for="status1" class="form-check-label">
									<input type="radio" id="status1" name="status" class="form-check-input" value="1">
									发布
								</label>
							</div>
						</div>
					
					<div class="form-group">
						<div class="col-sm-8 col-sm-offset-2">
							<button class="btn btn-md btn-primary" type="submit">提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<%@ include file="/common/include/head_footer.jsp"%>
	</body>
</html>